package com.Controller;

import com.Service.sturootService;
import com.bean.studentLogin;
import com.bean.sturoot;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class indexController {

    @Autowired
    private sturootService service;

    @RequestMapping("/login")
    public String login(studentLogin slogin){
        List <sturoot> lists=service.findAllRoot();

            for (int i = 0; i < lists.size(); i++) {
            /*
            用if判断用户提交的和数据库中学生的账号密码是否一直，不一致就返回错误页面，一致则允许学生进入添加信息页面
            * */
                if (slogin.getNumber() == lists.get(i).getAdmin() && slogin.getPassword().
                        equals(lists.get(i).getPassword())) {
                    return "test";
                }
            }

        return "errorPage";
    }

    @RequestMapping("/register")
    public  String register(){
        return "errorPage";
    }


}
